namespace Lays.Manage.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class UpdateNewsEntity_2 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.NewsTypeNews", "NewsType_Id", "dbo.NewsTypes");
            DropForeignKey("dbo.NewsTypeNews", "News_Id", "dbo.News");
            DropIndex("dbo.NewsTypeNews", new[] { "NewsType_Id" });
            DropIndex("dbo.NewsTypeNews", new[] { "News_Id" });
            AddColumn("dbo.News", "NewsType_Id", c => c.Int());
            CreateIndex("dbo.News", "NewsType_Id");
            AddForeignKey("dbo.News", "NewsType_Id", "dbo.NewsTypes", "Id");
            DropTable("dbo.NewsTypeNews");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.NewsTypeNews",
                c => new
                    {
                        NewsType_Id = c.Int(nullable: false),
                        News_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.NewsType_Id, t.News_Id });
            
            DropForeignKey("dbo.News", "NewsType_Id", "dbo.NewsTypes");
            DropIndex("dbo.News", new[] { "NewsType_Id" });
            DropColumn("dbo.News", "NewsType_Id");
            CreateIndex("dbo.NewsTypeNews", "News_Id");
            CreateIndex("dbo.NewsTypeNews", "NewsType_Id");
            AddForeignKey("dbo.NewsTypeNews", "News_Id", "dbo.News", "Id", cascadeDelete: true);
            AddForeignKey("dbo.NewsTypeNews", "NewsType_Id", "dbo.NewsTypes", "Id", cascadeDelete: true);
        }
    }
}
